%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Edited by Shu Jiang, 2011.
% ALL RIGHTS ARE RESERVED.
% mailto: shujiang@tamu.edu
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% beaming data
function [ave_data,ave_time] = BeamData(data_time,data)
% 1/240
    j = 1;
    sum_data = 0;
    k=0;
%     sf =201; % 2 steps
    sf = 101; % sampling frequence
% get data
    for i=1:size(data,2)
        if data_time(i)<=j*1/sf; %[0:1/240]
            sum_data = sum_data+data(i);
            k=k+1;
        else
            ave_data(j) = sum_data/k;
            ave_time(j) = (j-1)*1/sf+1/(2*sf);
            sum_data = 0;
            j = j+1;
            k = 0;
        end
    end

end